package cn.kinoko.mapper.common;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author kinoko
 */
@Mapper
public interface CommonMapper {

    @Select("select * from ${tableName} where ${idField} = ${id} and is_delete = 0 for update")
    Map<String, Object> findObjById(@Param("tableName") String tableName, @Param("idField") String idField, @Param("id") Long id);

    /**
     * 根据业务id集合查询对象
     * @param tableName 表名
     * @param idField 主键字段
     * @param bizIds 业务id集合
     * @return 对象列表
     */
    List<Map<String, Object>> findObjByIds(@Param("tableName") String tableName, @Param("idField") String idField, @Param("bizIds") List<Long> bizIds);

    /**
     * 清理逻辑删除数据
     */
    void clearLogicDelData();
}
